package three;


/**
 * Description TODO
 *
 * @author yangchuan
 * @version 1.0 create at 2021/3/20
 */
public class ArrayQueue<E> {

    private Array<E> array;

    public ArrayQueue(int capacity) {
        array = new Array<E>(capacity);
    }

    public ArrayQueue() {
        array = new Array<E>(10);
    }

    public boolean empty() {
        return array.isEmpty();
    }

    public void push(E e) {
        array.addLast(e);
    }

    public E pop() {
        return array.removeFirst();
    }

    public E peek() {
        return array.getFirst();
    }

    public static void main(String[] args) {
        ArrayQueue<Integer> queue = new ArrayQueue<Integer>();

        for (int i = 0; i < 10; i++) {
            queue.push(i);
        }

        for (int i = 0; i < 5; i++) {
            System.out.println(queue.pop());

        }

        for (int i = 0; i < 5; i++) {
            System.out.println(queue.peek());

        }
    }
}
